#pragma once

#include "Workbench.h"

class OffscreenManager {
public:
	virtual CDC * GetOffscreenDC() = 0;
	virtual void OnSize(int cx, int cy) { }
};

class OffscreenView;

class OffscreenOwner : public OffscreenManager {
private:
	OffscreenView &	m_View;
	CBitmap			m_Bmp;
	CDC				m_DC;
public:
	OffscreenOwner(OffscreenView &);
	~OffscreenOwner();
public:
	virtual CDC * GetOffscreenDC()
		{ return &m_DC; }
	virtual void OnSize(int cx, int cy);
};

class OffscreenView : public Workbench
{
protected:
	OffscreenView(); // protected constructor used by dynamic creation

// Attributes
protected:
	OffscreenOwner	m_DefaultManager;

// Operations
protected:	   
	virtual bool GetDoubleBuffering() const
		{ return true; }

	virtual OffscreenManager & GetOffscreenManager()
		{ return m_DefaultManager; }

	OffscreenManager & GetDefaultManager()
		{ return m_DefaultManager; }

	virtual CDC * GetOffscreenDC();

	virtual void DoPaint(CDC * pDC, const CRgn &) = 0;

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(OffscreenView)
protected:
	virtual void OnDraw(CDC* pDC) { };
	//}}AFX_VIRTUAL

// Implementation
protected:
	virtual ~OffscreenView();

protected:
	virtual void HandlePaint();
	virtual BOOL HandleEraseBkgnd(CDC* pDC);
	virtual void HandleSize(UINT nType, int cx, int cy);
};

//{{AFX_INSERT_LOCATION}}
